package com;


import com.pojo.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.Reader;

public class UserTest {
    @Test
    public void userFindByIdTest(){
        String resources = "mybatis-config.xml";
        Reader reader = null;
        try {
            reader = Resources.getResourceAsReader(resources);
        }catch (Exception e){
            e.printStackTrace();
        }
        SqlSessionFactory sqlMapper =
                new SqlSessionFactoryBuilder().build(reader);
        SqlSession sqlSession = sqlMapper.openSession();
        User user = sqlSession.selectOne("findById", 1);
        System.out.println(user.getUnname());
        sqlSession.close();

    }
}
